IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_sp_MediaContentDelete]') AND type in (N'P', N'PC'))
	DROP PROCEDURE [dbo].[cms_sp_MediaContentDelete]
GO
create procedure [dbo].[cms_sp_MediaContentDelete]
(
@Id int
)
as
delete from dbo.MediaFiles
where MediaFileId in
	(select MediaFiles.MediaFileId from dbo.MediaFiles
	inner join dbo.MediaContentFileLinks
	on MediaFiles.MediaFileId = MediaContentFileLinks.MediaFileId
	where MediaContentFileLinks.MediaContentId = @Id)
delete from dbo.MediaContents
where MediaContentId = @Id


GO

